package wmhsudoku.board;

import java.io.BufferedWriter;
import java.io.FileWriter;

public abstract class Solver {
	protected Map sudoku;
	protected Map mask;
	protected double energy = 0.0;
	protected int iterations = 0;
	protected BufferedWriter out; 
	protected boolean printConsole = false;
	protected boolean printFile = false;
	
	
	protected ErrorMatrix eMatrix = new ErrorMatrix();

	public Solver(Board board) {
		this.sudoku = board.getSudoku();
		this.mask = board.getMask();
	}
	
	public Solver(Board board, boolean printConsole, boolean printFile) {
		this(board);
		this.printConsole = printConsole;
		this.printFile = printFile;
	}
	
	public abstract void solve();
	
	public abstract boolean solveStep();
	
	public void init() {
		iterations = 0;
		eMatrix.countAll(sudoku);
	}
	
	
	protected void initSolution() {
		for (int i = 0; i<9; ++i)
			for (int j=0; j<9; ++j) {
				if (mask.getField(i, j) == 1) {
					sudoku.setField(i, j, (int)(Math.random()*9 +1));
				}
			}
	}
	
	protected void saveToFile(String s) {
		
	}
}
